package br.ufmg.dcc.simulesspl.aspect;

import br.ufmg.dcc.simulesspl.GameConfiguration;
import br.ufmg.dcc.simulesspl.di.GuiceInjector;
import br.ufmg.dcc.simulesspl.model.EngineerCard;
import br.ufmg.dcc.simulesspl.model.GameBoard;

public aspect ChaosMode {

	private pointcut bugProbabilityMethodCall(EngineerCard engineer) :  
		if(GameConfiguration.CHAOS_MODE) && call(double EngineerCard.getBugProbability()) && target(engineer);

	double around(EngineerCard engineer) : bugProbabilityMethodCall(engineer) {
		GameBoard gameBoard = GuiceInjector.get().getInstance(GameBoard.class);

		double probability = proceed(engineer);
		return probability + gameBoard.getTotalBugs() * 0.1;
	}

}
